from flask import Flask, request, jsonify
from module.asr import audio_to_text
from module.llm import ask_llm
from config.settings import OPENAI_API_KEY

app = Flask(__name__)

@app.route('/qa', methods=['POST'])
def qa():
    audio_file = request.files['audio']
    audio_path = '/tmp/input.wav'
    audio_file.save(audio_path)
    question = audio_to_text(audio_path)
    answer = ask_llm(question, OPENAI_API_KEY)
    return jsonify({'question': question, 'answer': answer})

if __name__ == '__main__':
    app.run(debug=True) 